# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=libsamplerate
pkgver=0.2.2
pkgrel=1
pkgdesc="An audio sample rate conversion library"
arch=('x86_64')
url="https://libsndfile.github.io/libsamplerate/"
license=('BSD')
depends=('glibc')
makedepends=('alsa-lib' 'cmake' 'libsndfile' 'opus')
checkdepends=('fftw')
provides=('libsamplerate.so')
source=("https://github.com/libsndfile/${pkgname}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.sig})
sha512sums=('d23ae54d23209ba22baae9e5fd178dd8e0e99205dada7e7c3a7b3a3d8cf816ed427a411bfeb008427f64da7767d645edce40811f238af11c8c386f5ef25a9f0c'
            'SKIP')
b2sums=('71b1e8a1644a94fff019abc6bf98c557df84994293f1e9bc651ad3ad3f0afeb24f54b8c75fc26e5202ae7c3a3e34e783fd1be7f7c6fdefe9eac9a5dfe7100b91'
        'SKIP')
validpgpkeys=('31D95CAB6D80D262244A1750A47620E801E47E95')  # David Seifert soap@gentoo.org

build() {
  cd "${pkgname}-${pkgver}"
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE='None' \
        -DBUILD_SHARED_LIBS=ON \
        -Wno-dev \
        -B build \
        -S .
  make VERBOSE=1 -C build
}

check() {
  cd "${pkgname}-${pkgver}"
  make test -C build
}

package() {
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install -C build
  install -vDm 644 {AUTHORS,NEWS,README.md,ChangeLog} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
